package com.applet.mallappletbackstage.utils;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.applet.mallappletbackstage.entity.ReleaseWork;
import com.applet.mallappletbackstage.entity.vo.ExcelWork;
import com.applet.mallappletbackstage.mapper.ReleaseWorkMapper;

public class EasyReadListener extends AnalysisEventListener<ExcelWork> {

    private ReleaseWorkMapper releaseWorkMapper;

    public EasyReadListener(ReleaseWorkMapper releaseWorkMapper) {
        this.releaseWorkMapper = releaseWorkMapper;
    }

    @Override
    public void invoke(ExcelWork data, AnalysisContext context) {
        System.out.println(data);
        ReleaseWork releaseWork = new ReleaseWork()
                .setClaim(data.getClaim())
                .setCompany(data.getCompany())
                .setName(data.getName())
                .setNumber(data.getNumber())
                .setTitle(data.getTitle())
                .setPhone(data.getPhone())
                .setTypeOfWork(data.getTypeOfWork());
        releaseWorkMapper.insert(releaseWork);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
    }
}
